package org.colcon.web.model;

import java.util.HashMap;
import java.util.Map;

import org.colcon.web.model.framework.IUser;

public class User extends Agent implements IUser
{
	public String getType(){return "user";}
	
	private static final long serialVersionUID = 1607528648316514525L;
	
	protected static final String
	
		// arguments
		EMAIL = "email",
		PASSWORD = "password",
		
		// link containers
		TITLES = "titles";

	public User()
	{
		this(new HashMap<String, String>());
	}
	
	public User(Map<String, String> args)
	{
		this(args.get(ID), args.get(EMAIL), args.get(PASSWORD), args.get(CHILDREN));
	}
	
	public User(String id, String email, String password, String children)
	{
		super("colcon/users", id, children);
		
		setArg(EMAIL, email);
		setArg(PASSWORD, password);
	}
	
	public String getEmail()
	{
		return getArg(EMAIL);
	}
	
	//TODO: this should be encrypted
	public String getPassword()
	{
		return getArg(PASSWORD);
	}

	public String titles()
	{
		return getPath() + '/' + "titles";
	}
	
	public String getTitlePath(String title)
	{
		return titles() + '/' + title;
	}
}
